package com.cy.pj.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Locale;


@Aspect
@Component
@Order(2)
public class SysPriorityTest {

    public SysPriorityTest(){
        System.out.println("SysPriorityTest init.....");
    }

    @Pointcut("bean(categoryImple)")
    public void doLog(){}




    @After("doLog()")
    public void testAfter(){
        System.out.println("this is After Advice.");
    }

    @Before("doLog()")
    public void testBefore(JoinPoint joinPoint){
        System.out.println("this is  Before advice.");
    }

    @AfterReturning("doLog()")
    public void testAfterReturning(){
        System.out.println("this is  AfterReturning advice.");
    }

    @Around("doLog()")
    public Object testAround(ProceedingJoinPoint  joinPoint){
        System.out.println("this is Around advice.");
        Object  o=null;
        try {
             o=joinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
        return  o;
    }

    @AfterThrowing("doLog()")
    public void testAfterThrowing(){
        System.out.println("this is AfterThrowing advice.");
            int t=0;
            try {

                t=10/t;
            } catch (Throwable throwable) {
                throwable.printStackTrace();

            }



    }
}
